<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--点击事件中调用方法-->
<input type="button" value="按钮" onclick="fn1()">
<script>
    //无参无返回值
   function fn1() {
        alert("fn1");
   }
   fn1();
    //有参无返回值
    function fn2(name,age) {
        alert(name+":"+age);
    }
    fn2("张飞",18);
    
    //无参有返回值
    function fn3() {
        return "我是返回值";
    }
    alert(fn3());
    //有参有返回值
   function fn4(x,y) {
        return x*y;
   }
   let result =fn4(8,9);
   alert(result);
    //第二种声明方法的方式
   let fn5 =function (name,age) {
        alert(name+":"+age);
   }
   fn5("关羽",32);
   let fn6 =new Function("name","age","alert(name+':'+age)");
   fn6("刘备",50);


</script>
</body>
</html>